#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<string>

using namespace std;

class Product
{
public:
	void methodSame()
	{

	}
	virtual void methodDiff() = 0;
};

class ProductA : public Product
{
public:
	void methodDiff()
	{
		cout << "I am A" << endl;
	}
};

class ProductB : public Product
{
public:
	void methodDiff()
	{
		cout << "I am B" << endl;
	}
};

class Factory
{
public:
	static Product* getProduct(string str)
	{
		Product* product = nullptr;
		if (str == "A")
			product = new ProductA();
		else if (str == "B")
			product = new ProductB();
		
		return product;
	}
};

int main()
{
	Product* product = nullptr;
	product = Factory::getProduct("A");
	product->methodSame();
	product->methodDiff();
	return 0;
}
